/// [Largest prime factor](https://projecteuler.net/problem=3)
fn main() {
    for num in &[13195, 600851475143] {
        println!("{}內的最大质因数为{}", num, largest_prime_factor(*num));
    }
}
/// 记录已知质因数，加速判断；平方缩小遍历范围
fn largest_prime_factor(length: usize) -> usize {
    let mut len = length;
    let mut num = 2_usize;
    while num * num < len {
        while len % num == 0 {
            len /= num;
        }
        num += 1;
    }
    len
}
